$OpenBSD: patch-libbacktrace_backtrace_c,v 1.3 2014/04/03 11:40:02 jasper Exp $

- BT_MAX_DEPTH and struct bt_frame should not be exposed in a public header
  since they're internal to libbacktrace.

- __builtin_return_address() and __builtin_frame_address()
  may not always have a !0 argument.

--- libbacktrace/backtrace.c.orig	Fri Sep 10 14:19:27 2010
+++ libbacktrace/backtrace.c	Wed Sep 26 12:54:22 2012
@@ -35,7 +35,13 @@ __attribute__((unused)) static const char *cvstag = "$
 
 #define BT_GET_DEPTH		(1)
 #define BT_ADD_CR		(1)
+#define BT_MAX_DEPTH            (128)
 
+struct bt_frame {
+	Dl_info			bt_dlinfo;
+	unsigned int		line;
+};
+
 #define HANDLE_FRAME(depth, idx, btaddr)				\
 	case depth:							\
 		if (!__builtin_frame_address(depth + 1))		\
@@ -59,6 +65,7 @@ bt_create_backtrace(void **buffer, int depth, int flag
 		/* number of HANDLE_FRAME must match BT_MAX_DEPTH */
 		switch (i) {
 		HANDLE_FRAME(0, i, addr);
+#ifndef __BUILTIN_HACK
 		HANDLE_FRAME(1, i, addr);
 		HANDLE_FRAME(2, i, addr);
 		HANDLE_FRAME(3, i, addr);
@@ -186,6 +193,7 @@ bt_create_backtrace(void **buffer, int depth, int flag
 		HANDLE_FRAME(125, i, addr);
 		HANDLE_FRAME(126, i, addr);
 		HANDLE_FRAME(127, i, addr);
+#endif
 		default:
 			goto done;
 		}
